﻿using System;
using fastCSharp;

namespace diantou.web.onlineJudge
{
    /// <summary>
    /// 分组菜单
    /// </summary>
    struct groupMenu
    {
        /// <summary>
        /// 是否重新加载视图
        /// </summary>
        [fastCSharp.code.cSharp.webView.outputAjax]
        public bool ViewOnly;
        /// <summary>
        /// 是否根据话题分组
        /// </summary>
        public bool IsTopic;
        /// <summary>
        /// 问题分组集合
        /// </summary>
        public diantou.dataAccess.problemGroup[] Groups
        {
            get
            {
                if (ViewOnly) return null;
                if (diantou.dataAccess.clientCache.ProblemGroup.IsData)
                {
                    diantou.dataAccess.problemGroup[] groups = new dataAccess.problemGroup[diantou.dataAccess.clientCache.ProblemGroup.Count + 1];
                    groups[0] = diantou.dataAccess.problemGroup.AllGroup;
                    int index = 1;
                    foreach (diantou.dataAccess.problemGroup group in diantou.dataAccess.clientCache.ProblemGroup.CacheValues) groups[index++] = group;
                    return groups;
                }
                else
                {
                    diantou.dataAccess.problemGroup[] cache = diantou.dataAccess.tcpCall.problemGroup.getCache();
                    diantou.dataAccess.problemGroup[] groups = new dataAccess.problemGroup[cache.Length + 1];
                    groups[0] = diantou.dataAccess.problemGroup.AllGroup;
                    cache.CopyTo(groups, 1);
                    return groups;
                }
            }
        }
        /// <summary>
        /// 分组话题集合
        /// </summary>
        public diantou.dataAccess.topic[] Topics
        {
            get { return ViewOnly ? null : topicProblem.Topics; }
        }
    }
}
